package com.btcode.log;

import org.apache.log4j.Logger;

public class Log4Jer implements ILog {

    private Logger log;
    /**
     * 日志是否开启
     */
    private boolean isLog = true;

    public Log4Jer(Logger log) {
        this.log = log;
    }

    @Override
    public void info(Object message, Throwable throwable) {
        if (!isLog) {
            return;
        }
        log.info(message, throwable);
    }

    @Override
    public void error(Object message, Throwable throwable) {
        if (!isLog) {
            return;
        }
        log.error(message, throwable);
    }

    @Override
    public void debug(Object message, Throwable throwable) {
        if (!isLog) {
            return;
        }
        log.debug(message, throwable);
    }

    @Override
    public String getName() {
        return log.getName();
    }

    @Override
    public void info(Object message) {
        info(message, null);
    }

    @Override
    public void error(Object message) {
        error(message, null);
    }

    @Override
    public void debug(Object message) {
        debug(message, null);
    }

    @Override
    public void logOn() {
        isLog = true;
    }

    @Override
    public void logOff() {
        isLog = false;
    }

}
